<template>
  <div class="qualityBatch">
    <el-tabs v-model="activeName" @tab-click="handleClick" type="card">
      <el-tab-pane label="试纸批号" name="first">
        <v-table :header="header" :tableList="tableData"></v-table>
      </el-tab-pane>
      <el-tab-pane label="质控批号" name="second">
        <v-table :header="header_zk" :tableList="tableData_zk"></v-table>
      </el-tab-pane>
    </el-tabs>
    <v-pagination :total="total" @currentPage="currentPage"></v-pagination>
  </div>
</template>

<script>
// 引入表格
import vTable from "../../components/Table/index";
// 引入分页
import vPagination from "@/components/pagination/index";

export default {
  data() {
    return {
      activeName: "first",
      header: [
        {
          prop: "departmentName",
          label: "科室",
        },
        {
          prop: "articleTry",
          label: "试纸批次号",
        },
        {
          prop: "dateInProduced",
          label: "生产日期",
        },
        {
          prop: "liveTime",
          label: "使用期限",
        },
        {
          prop: "addTime",
          label: "操作时间",
        },
        {
          prop: "userName",
          label: "操作人",
        },
        {
          prop: "remark",
          label: "备注",
        },
      ],
      tableData: [],
      header_zk: [
        {
          prop: "departmentName",
          label: "科室",
        },
        {
          prop: "qualityControlName",
          label: "名称",
        },
        {
          prop: "qualityMin",
          label: "最小值",
        },
        {
          prop: "qualityMax",
          label: "最大值",
        },
        {
          prop: "addTime",
          label: "操作时间",
        },
        {
          prop: "userName",
          label: "操作人",
        },
        {
          prop: "operation",
          label: "操作",
          render: (h, data) => {
            return (
              <div>
                <el-button
                  type="text"
                  onClick={() => {
                    this.editquality(data.row);
                  }}
                >
                  修改
                </el-button>
                <el-divider direction="vertical"></el-divider>
                <el-button
                  type="text"
                  onClick={() => {
                    this.delquality(data.row);
                  }}
                >
                  删除
                </el-button>
              </div>
            );
          },
        },
      ],
      tableData_zk: [],
      total: 10,
    };
  },
  props: {
    // precisequeryData: {
    //   type: Object,
    //   required: true,
    // },
  },
  components: {
    vTable,
    vPagination,
  },
  mounted() {
    // 纸批次号信息
    this.handleClick();
  },
  methods: {
    // tabs切换
    handleClick() {
      this.page = 1;
      this.$emit("BatchType", this.activeName);
      if (this.activeName == "first") {
        this.getArticleTryInfo({});
      } else {
        this.getQualityControl({});
      }
    },
    // 试纸批次号信息
    getArticleTryInfo(value) {
      let data = {
        departmentId: value.departmentId ? value.departmentId : "",
        startTime: value.startTime ? value.startTime : "",
        endTime: value.endTime ? value.endTime : "",
        current: value.current ? value.current : "",
      };
      // console.log(data)
      this.$api
        .getArticleTryInfo(data)
        .then((res) => {
          this.tableData = res.data.data;
          this.total = res.total;
        })
        .catch((err) => {
          this.tableData = [];
        });
    },
    // 质控批号
    getQualityControl(value) {
      let data = {
        departmentId: value.departmentId ? value.departmentId : "",
        current: value.current ? value.current : "",
      };
      this.$api
        .getQualityControl(data)
        .then((res) => {
          this.tableData_zk = res.data.data;
          this.total = res.total;
        })
        .catch((err) => {
          this.tableData_zk = [];
        });
    },
    // 当前页码
    currentPage(page) {
      this.page = page;
      this.$parent.search(this.page);
      // if (this.activeName == "first") {
      //   this.$parent.search(this.page);
      // } else if (this.activeName == "second") {
      //   this.getQualityControl(data);
      // }
    },
    // 编辑质控批号
    editquality(row) {
      console.log(row);
      // let data = {
      //   qualityId : 17
      // };
      // this.$api
      //   .deleteQualityControl(data)
      //   .then((res) => {
      //     this.tableData_zk = res.data.data;
      //     this.total = res.total;
      //   })
      //   .catch((err) => {
      //     this.tableData_zk = [];
      //   });
    },
    // 删除质控批号
    delquality(row) {
      console.log(row);
    },
  },
};
</script>

<style lang="scss" scoped>
.qualityBatch {
  .el-tabs {
    & >>> .el-tabs__header {
      // background-color: aqua;
      border: 0;
      .el-tabs__nav {
        border: 0;
        .el-tabs__item {
          border: 0;
          padding: 0;
          margin-right: 20px;
          &:hover {
            color: #01a7f0;
          }
        }
        .is-active.el-tabs__item {
          color: #01a7f0;
        }
      }
    }
  }
}
</style>